data/selinux, packaging: assign a default label for /tmp/snap-private-tmp, set it during installation - #17403
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes SELinux labeling for /tmp/snap-private-tmp on RPM-based systems by adding a default file context for the directory and ensuring it is relabeled after the snappy SELinux policy module is installed, so snap-confine and the snap CLI behave correctly under SELinux enforcement.
Changes:
- Add an SELinux file-context entry to label
/tmp/snap-private-tmpassnappy_tmp_t. - Update Fedora and openSUSE RPM
%post selinuxscriptlets to create the directory (if needed) andrestoreconit after installing the SELinux module. - Allow
snappy_cli_ttogetattrthesnappy_tmp_tdirectory so thesnapcommand can probe for its presence.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packaging/opensuse/snapd.spec | Create and relabel /tmp/snap-private-tmp after loading the SELinux module on openSUSE. |
| packaging/fedora/snapd.spec | Create and relabel /tmp/snap-private-tmp after loading the SELinux module on Fedora. |
| data/selinux/snappy.te | Permit snap CLI domain to getattr the labeled directory for existence probing. |
| data/selinux/snappy.fc | Define the default SELinux label for /tmp/snap-private-tmp as snappy_tmp_t. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #17403 +/- ##
=======================================
Coverage 78.93% 78.93%
=======================================
Files 1391 1390 -1
Lines 196009 195981 -28
Branches 2462 2462
=======================================
- Hits 154727 154707 -20
+ Misses 32013 31993 -20
- Partials 9269 9281 +12
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Thu Jul 23 22:57:37 UTC 2026 Failures:Preparing:
Executing:
Restoring:
Skipped tests from snapd-testing-skipIf you wish to have any of the below tests run in your PR, in your PR description, add 'unskip:' followed by a copy-and-pasted list of the below tests you wish to run (unskip plus test list must be valid yaml)
|
Signed-off-by: Maciej Borzecki <maciej.borzecki@canonical.com>
…ling the selinux policy package Signed-off-by: Maciej Borzecki <maciej.borzecki@canonical.com>
…mp presence Signed-off-by: Maciej Borzecki <maciej.borzecki@canonical.com>
2991227 to
299a253
Compare
The recently merged changes from 2.76.3 added a line creating
/tmp/snap-private-tmpin%post. However, since we have no default label assigned for that path and the%postscript is executed by rpm, the path got incorrect label:The branch updates the default file labels so that we get
snappy_tmp_t, ensures we get the right label during installation and allows thesnapcommand to probe for the directory.